package com.uphone.magicleafteacher.pro.activity;

import android.support.v7.widget.RecyclerView;
import android.view.View;

import com.google.gson.Gson;
import com.radish.baselibrary.Intent.IntentUtils;
import com.uphone.magicleafteacher.MyApp;
import com.uphone.magicleafteacher.base.BaseListActivity;
import com.uphone.magicleafteacher.http.ApiService;
import com.uphone.magicleafteacher.pro.adapter.BookBorrowingAdapter;
import com.uphone.magicleafteacher.util.CommonUtil;
import com.uphone.magicleafteacher.util.GsonUtils;
import com.uphone.magicleafteacher.vo.BookBorrowingBean;

import java.util.List;

import io.reactivex.Observable;
import okhttp3.ResponseBody;

public class BookBorrowingActivity extends BaseListActivity<BookBorrowingBean.FollowWorkBean, BookBorrowingAdapter> {
    @Override
    protected Observable<ResponseBody> loadData(ApiService apiService) {
        return MyApp.apiService(ApiService.class)
                .studentFollowWork(CommonUtil.getTeacherId(), page + "", "10");
    }

    @Override
    protected List<BookBorrowingBean.FollowWorkBean> getDataList(String json) {
        BookBorrowingBean bookBorrowingBean = GsonUtils.getGson().fromJson(json, BookBorrowingBean.class);
        if (bookBorrowingBean != null)
            return bookBorrowingBean.getFollowWork();
        return null;
    }

    @Override
    protected void itemClick(BookBorrowingAdapter adapter, View view, int position) {
        CommonUtil.startIntentTitle(this, BookBorrowingDetailActivity.class, mAdapter.getItem(position).getFollowId(), mAdapter.getItem(position).getBookName());
    }

    @Override
    protected BookBorrowingAdapter initAdapter() {
        return new BookBorrowingAdapter();
    }

    @Override
    protected void initBundle() {

    }

    @Override
    protected void initTitle() {
        initTitle("跟读指导");
//        DefaultNavigationBar navigationBar = initTitle("图书借阅", "记录", v -> {
//            // 借阅记录
////            CommonUtil.startIntent(this, BookBorrowingRecordActivity.class);
//        });
//        TextView rightTitle = (TextView) navigationBar.getRightTitle();
//        rightTitle.setTextColor(getResources().getColor(R.color.themecolor));
//
//        ll.setBackgroundColor(Color.WHITE);
//        int dp7 = SizeUtils.dp2px(7);
//        recyclerView.setPadding(dp7, 0, dp7, dp7);
//        View searchView = View.inflate(this, R.layout.layout_search, null);
//        ll.addView(searchView, 0);
    }

    @Override
    protected RecyclerView.LayoutManager getLayoutManager() {

        return null;
    }
}
